package entities.concept;

import option.KBVocabulary;
import entities.role.Role;

public final class DomainConceptEQ<S, T> extends DomainConcept<S, T> {

	public DomainConceptEQ(S f, T k) {
		super(f, k);
	}

	@Override
	public boolean equals(Object obj) {
		return super.equals(obj) && this.getClass().equals(obj.getClass());
	}

	private volatile int hashCode = 0;

	@Override
	public int hashCode() {
		if (hashCode != 0) {
			return hashCode;
		}
		final int prime = 31;
		int result = KBVocabulary.EQ.hashCode();
		result = prime * result + ((f == null) ? 0 : f.hashCode());
		result = prime * result + ((k == null) ? 0 : k.hashCode());
		hashCode = result;
		return result;
	}

	@Override
	public String toString() {
		return "(" + (f == null ? "NULL" : f.toString()) + " = "
				+ (k == null ? "NULL" : k.toString()) + ")";
	}

	@Override
	public Concept getPrimeCopy() {
		return new DomainConceptEQ<Role, Object>(Role.createRoleAsIs(this.f
				.toString() + Concept.PRIME), this.k);
	}

	@Override
	public String toSerializedString() {
		return " (" + KBVocabulary.EQ + " " + this.getSerializedItem(f) + " "
				+ this.getSerializedItem(k) + ")";
	}

}
